//
//  HomeComtypeCell.m
//  Ginix
//
//  Created by 冯志强 on 2025/2/23.
//

#import "HomeComtypeCell.h"
#import "HomeComtypeView.h"

@interface HomeComtypeCell()
@property (nonatomic,strong) UIImageView * iconView;
@property (nonatomic,strong) HomeComtypeView * noView;
@property (nonatomic,strong) HomeComtypeView * leView;
@property (nonatomic,strong) HomeComtypeView * laView;
@property (nonatomic,strong) HomeComtypeView * huView;
@property (nonatomic,strong) HomeComtypeView * hoView;

@end

@implementation HomeComtypeCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];
    self.selectionStyle = UITableViewCellSelectionStyleNone;
}

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        [self setSubViewLayout];
    }
    return self;
}
-(void)setSubViewLayout{
    
    self.backgroundColor = UIColor.clearColor;
    self.contentView.backgroundColor = UIColor.clearColor;
    
    [self addSubview:self.iconView];
    [_iconView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_offset(23 * FMScaleX);
        make.size.mas_offset(CGSizeMake(110 * FMScaleX, 110 * FMScaleX));
        make.centerY.equalTo(@0);
    }];
    [self addSubview:self.noView];
    [_noView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.iconView.mas_left).offset(94 * FMScaleX);
        make.size.mas_offset(CGSizeMake(210 * FMScaleX, 24 * FMScaleX));
        make.top.mas_offset(18 * FMScaleX);
    }];
    [self addSubview:self.leView];
    [_leView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.equalTo(self.noView);
        make.left.equalTo(self.iconView.mas_right).offset(4 * FMScaleX);
        make.top.equalTo(self.noView.mas_bottom).offset(8 * FMScaleX);
    }];
    [self addSubview:self.laView];
    [_laView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.equalTo(self.noView);
        make.left.equalTo(self.iconView.mas_right).offset(10 * FMScaleX);
        make.top.equalTo(self.leView.mas_bottom).offset(8 * FMScaleX);
    }];
    [self addSubview:self.huView];
    [_huView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.equalTo(self.noView);
        make.left.equalTo(self.iconView.mas_right).offset(4 * FMScaleX);
        make.top.equalTo(self.laView.mas_bottom).offset(8 * FMScaleX);
    }];
    [self addSubview:self.hoView];
    [_hoView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.equalTo(self.noView);
        make.top.equalTo(self.huView.mas_bottom).offset(8 * FMScaleX);
        make.left.equalTo(self.iconView.mas_left).offset(94 * FMScaleX);
    }];
}

-(void)setInfoModel:(HomeAllCheckModel *)infoModel{
        
    if (infoModel.result.score >= 0 && infoModel.result.score <= 25) {
        self.iconView.image = [UIImage imageNamed:@"Home_com_lus_icon"];
    }else if (infoModel.result.score >=26  && infoModel.result.score <= 50){
        self.iconView.image = [UIImage imageNamed:@"Home_com_lns_icon"];
    }else if (infoModel.result.score >= 51 && infoModel.result.score <= 75){
        self.iconView.image = [UIImage imageNamed:@"Home_com_huangs_icon"];
    }else{
        self.iconView.image = [UIImage imageNamed:@"Home_com_hongs_icon"];
    }
    
}

-(UIImageView *)iconView{
    
    if (!_iconView) {
        _iconView = [[UIImageView alloc]init];
        _iconView.image = [UIImage imageNamed:@"Home_com_nos_icon"];
    }
    return _iconView;
}

-(HomeComtypeView *)noView{
    
    if (!_noView) {
        _noView = [[HomeComtypeView alloc]init];
        [_noView setIndex:0];
    }
    return _noView;
}
-(HomeComtypeView *)leView{
    
    if (!_leView) {
        _leView = [[HomeComtypeView alloc]init];
        [_leView setIndex:1];
    }
    return _leView;
}
-(HomeComtypeView *)laView{
    
    if (!_laView) {
        _laView = [[HomeComtypeView alloc]init];
        [_laView setIndex:2];
    }
    return _laView;
}
-(HomeComtypeView *)huView{
    
    if (!_huView) {
        _huView = [[HomeComtypeView alloc]init];
        [_huView setIndex:3];
    }
    return _huView;
}
-(HomeComtypeView *)hoView{
    
    if (!_hoView) {
        _hoView = [[HomeComtypeView alloc]init];
        [_hoView setIndex:4];
    }
    return _hoView;
}
@end
